library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(p8105.datasets)
library(plotly)
##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following object is masked from 'package:graphics':
##
## layout
data("instacart")
instacart |>
janitor::clean_names()
## # A tibble: 1,384,617 × 15
## order_id product_id add_to_cart_order reordered user_id eval_set order_number
## <int> <int> <int> <int> <int> <chr> <int>
## 1 1 49302 1 1 112108 train 4
## 2 1 11109 2 1 112108 train 4
## 3 1 10246 3 0 112108 train 4
## 4 1 49683 4 0 112108 train 4
## 5 1 43633 5 1 112108 train 4
## 6 1 13176 6 0 112108 train 4
## 7 1 47209 7 0 112108 train 4
## 8 1 22035 8 1 112108 train 4
## 9 36 39612 1 0 79431 train 23
## 10 36 19660 2 1 79431 train 23
## # ℹ 1,384,607 more rows
## # ℹ 8 more variables: order_dow <int>, order_hour_of_day <int>,
## # days_since_prior_order <int>, product_name <chr>, aisle_id <int>,
## # department_id <int>, aisle <chr>, department <chr>
instacart |>
mutate() |>
plot_ly(
x = ~aisle, y = ~order_hour_of_day, type = "scatter", mode = "markers", alpha = 0.5)